import { objDeepCopy,getDateString } from "@/assets/js/common.js";
import commonObject from "@/assets/js/xm.js";
let Controller = {
	created() {
		this.init();
	},
	mounted() {
		
	},
	methods: {
		init() {
			this.getList();
		},
		//批量送检
		qualityBatch(){
			let tableData = this.Model.TableSelectData;
			if(!tableData.length){
				this.$message.error('暂无数据')
				return
			}
			let idList = []
			tableData.forEach(item=>{
				idList.push(item.id+'')
			})
			this.$confirm(`是否将${idList.length}件商品送检？`).then(() => {
				this.$ajax({
					method: 'post',
					url:`${this.apiTest}/supplier/supplierQualityRecord/qualityBatch`,
					data:idList
				}).then((res)=>{
					var data = res.data;
					if((data.status == 200 || data.status == 0) && data.result){
						this.$message.success('操作成功')
						this.getList()
					}else{
						this.$message.error(data.msg)
					}
				});
            })
			
			
		},
		//获取列表
		getList(barcode) {
			let params = {
				status:4
			}
			var apiTest = this.apiTest;
			this.$ajax({
					method: 'post',
					url:`${apiTest}/supplier/supplierQualityRecord/list`,
					data:{
						condition:params
					}
			    }).then((res)=>{
					var data = res.data;
					if((data.status == 200 || data.status == 0) && data.result){
						// data.result.indexNumber=this.Model.tableData.length+1
						// this.Model.tableData.push(data.result)
						data.result.result.forEach((item,index)=>item.indexNumber=index+1)
						this.Model.tableData = data.result.result
					}else{
						this.$message.error(data.msg)
					}
				});
		},
		selectedHighlight(data) {
			// 如果选中则添加高亮样式
			if (this.Model.TableSelectData.indexOf(data.row) > -1) {
				return {
					"background-color": "#FEF6EE"
				};
				return {}
			}
		},
		warehousing(row) {
			this.Model.warehousingDialogStatus = row.status;
			this.Model.warehousingDialogFlag = true;
		},
		handleSelectionChange(val) {
			this.Model.TableSelectData = val;
		},
		handleCurrentChange(val) {
			var params = this.Model.searchFromData;
			this.getList(this,params,val);
		},
		handleSizeChange(val) {
			var params = this.Model.searchFromData;
			this.getList(this,params,undefined,val);
		},
		cardClick(color) {
			this.Model.cardSelected = color;
		},
		showChild(val) {
			this.Model.searchFromData = val;
		},
		toSearch(val) {
			var params = this.Model.searchFromData
			let barcode = params?params.barcode:''

			this.getList(barcode);
		},
		toClear(val) {
			this.Model.searchFromData = {};
		},
		toExport(val) {
		  console.log(val);
		},
		tips(that,type,message) {
			that.$message({
				message: message,
				type: type
			});
		},
	},
	watch:{
		$route:{
		　　　handler(newValue, oldValue) {
				
		　　　},
		　　　deep: true
		},
  	
	},
	filters:{
		objFilters:function(value){
			
		}
	}
}
export default Controller;
